<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    </head>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        ul{
            overflow: hidden;
        }
        li{
            float: left;
            border: 1px solid rgb(17, 17, 15);
            padding: 10px 20px;
            cursor: pointer;
        }
        li.current{
                background:lime;
                color:white;
            }
        div{
            width: 500px;
            height: 500px;
            border: 1px solid greenyellow;
            display: none;
        }
        div.current{
                display: block;
            }
    </style>
    <body>
        <ul>
            <li class="current">猫</li>
            <li>狗</li>
            <li>豹</li>
            <li>狮</li>
        </ul>
        <section>
            <div class="current">
                <img src="images/1.jpeg" alt="">
            </div>
            <div>
                <img src="images/2.jpeg" alt="">
            </div>
            <div>
                <img src="images/3.jpeg" alt="">
            </div>
            <div>
                <img src="images/4.jpeg" alt="">
            </div>
        </section>

        <script>
            var a=document.getElementsByTagName('li');
            var b=document.getElementsByTagName('div');
            for(var i=0;i<a.length;i++){
                a[i].index=i;
                a[i].onclick=function(){
                    for(var j=0;j<a.length;j++){
                        a[j].className=''
                        b[j].className=''
                    }
                    this.className='current';
                    var n=this.index;
                    b[n].className='current';
        }
            }
           


        </script>
    </body>
    </html>